
<div class="col-md-9"  style="border: 1px solid #eee; min-height: 400px;" >
    <div class="form_filter_search">
        <?php
        $id_to_kategori = array();
        if (isset($list_kecamatan)) {
            ?>
            <form method="get" action="<?= site_url() . '/' . $controller ?>">
                <select id="chart_pilih_kabupaten" class="combo">
                    <option value="10">Banyuwangi</option>
                </select>
                <select id="select_kecamatan" class="combo" name="id_kecamatan" onchange="document.getElementById('select_kelurahan').value = 0;
                        this.form.submit();">
                    <option value="0">Semua Kecamatan</option>
                    <?php
                    foreach ($list_kecamatan as $kec) {
                        ?>
                        <option value="<?= $kec->no_kec; ?>" <? if ($id_kecamatan == $kec->no_kec) echo 'selected=""'; ?>><?= $kec->nama_kec; ?></option>
                        <?php
                    }
                    ?>
                </select>
                <select id="select_kelurahan" class="combo" name="id_kelurahan" onchange="this.form.submit()">
                    <option value="0">Semua Kelurahan</option>
                    <?php
                    foreach ($list_kelurahan as $kel) {
                        ?>
                        <option value="<?= $kel->no_kel; ?>" <? if ($id_kelurahan == $kel->no_kel) echo 'selected=""'; ?>><?= $kel->nama_kel; ?></option>
                        <?php
                    }
                    ?>
                </select>
                <select id="select_pekerjaan" class="combo" style="max-width:150px" name="key" onchange="this.form.submit()">
                    <option value="0">Semua Pendidikan</option>
                    <?php
                    foreach ($list_kategori as $kat) {
                        $id_to_kategori[$kat->kategori_id] = $kat->kategori;
                        ?>
                        <option value="<?= $kat->kategori_id; ?>" <? if ($key == $kat->kategori_id) echo 'selected=""'; ?>><?= $kat->kategori; ?></option>
                        <?php
                    }
                    ?>
                </select>
            </form>

            <?php
        }
        ?>
    </div>
    <div id="div_list">
        <table class="table table-striped">
            <tr>
                <th>No.</th>
                <th>NIK</th>
                <th>Nama</th>
                <TH>Tanggal Lahir</TH>
                <th>Pendidikan</th>
                <th></th>
            </tr>
            <?php
            $counter = $limit * $halaman;
            foreach ($list_data as $data) {
                $counter++;
                ?>
                <tr>
                    <td><?= $counter ?> </td>
                    <td><?= $data->NIK ?> </td>
                    <td><?= $data->NAMA_LGKP ?> </td>
                    <td><?=$data->TGL_LHR?></td>
                    <td><?php
            if (array_key_exists($data->kategori_id, $id_to_kategori))
                echo $id_to_kategori[$data->kategori_id];
            else
                echo ' ';
                ?></td>
                    <td>
                        <a href="javascript:void(0);" onclick="detil_penduduk('<?=$data->NIK?>');">Lihat Detil</a>
                    </td>
                </tr>
                <?php
            }
            ?>
        </table>
        <table style="width: 100%">
            <tr>
                <td>
                    Menampilkan <input type="text" id="c_halaman" value="<?= $halaman + 1; ?>"/> dari <?= $jumlah_halaman+1; ?> halaman <input type="button" value="Go" onclick="gotoPage()"/>
                </td>
                <td style="text-align: right">
                    <table style="float: right">
                        <tr>
                            <td>
                                <input type="button" value="Sebelumnya" onclick="prevPage();">
                            </td>
                            <td>
                                <input type="button" value="Selanjutnya" onclick="nextPage();">
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <form method="get" action="<?= site_url() . '/' . $controller ?>" id="form_halaman">
            <input type="hidden" name="halaman" value="<?= $halaman; ?>" id="current_halaman"/>
            <input type="hidden" name="id_kecamatan" value="<?= $id_kecamatan; ?>"/>
            <input type="hidden" name="id_kelurahan" value="<?= $id_kelurahan; ?>"/>
            <input type="hidden" name="key" value="<?= $key; ?>"/>
        </form>
    </div>
    <form action="<?=site_url()?>/home/search_data" method="post" id="form_lihat_detil">
        <input type="hidden" name="nik" id="nik_post" value=""/>
    </form>
</div>
</div>
</div> 
</section>
<script>
    function gotoPage() {
        document.getElementById('current_halaman').value = parseInt(document.getElementById('c_halaman').value - 1);
        document.getElementById('form_halaman').submit();
    }
    function nextPage() {
        document.getElementById('current_halaman').value++;
        document.getElementById('form_halaman').submit();
    }
    function prevPage() {
        document.getElementById('current_halaman').value--;
        document.getElementById('form_halaman').submit();
    }
    function detil_penduduk(nik){
        $('#nik_post').val(nik);
        $('#form_lihat_detil').submit();
    }
</script>